package tasks.OpportunitiesBaseData.MainView;
import java.sql.SQLException;
import java.util.ArrayList;

import resources.tasks.OpportunitiesBaseData.MainView.STGDBWrapperAfterAppliedFiltersHelper;
import tasks.OpportunitiesBaseData.ContentRule;
import tasks.OpportunitiesBaseData.Pattern;


import dbops.SQLOperator;
/**
 * Description   : Functional Test Script
 * @author dimitar.vasilev
 */
public class STGDBWrapperAfterAppliedFilters extends STGDBWrapperAfterAppliedFiltersHelper
{
	/**
	 * Script Name   : <b>STGDBWrapperAfterAppliedFilters</b>
	 * Generated     : <b>Dec 13, 2011 1:11:36 PM</b>
	 * Description   : Functional Test Script
	 * Original Host : WinNT Version 6.1  Build 7601 (S)
	 * 
	 * @since  2011/12/13
	 * @author dimitar.vasilev
	 */
	
	
	public ArrayList<String> get(Filters filter)
	{
		ContentRule rule = new ContentRule("MainView\\MainViewAfterAppliedFilters.sql");
		SQLOperator query = new SQLOperator();
		ArrayList<String> listOfDetailNumbers = new ArrayList<String>();
		ArrayList<ArrayList<String>> dbContentTmp = new ArrayList<ArrayList<String>>();
		try {
			dbContentTmp = query.executeSelect(rule.getRule(new Pattern("%IOT_GMU_NAME%",(filter.iot_gmu_name+"%")),
															new Pattern("%IMT_GMT_NAME%",(filter.imt_gmt_name+"%")),
															new Pattern("%GMR_NAME%",(filter.gmr_name+"%")),
															new Pattern("%CNTRY_NAME%",(filter.cntry_name+"%")),
															new Pattern("%TERR_TYPE_NAME%",(filter.terr_type_name+"%")),
															new Pattern("%SELLER_NAME%",(filter.seller_name+"%")),
															new Pattern("%BRAND_CD%",(filter.brand_cd+"%")),
															new Pattern("%SUBBRAND_CD%",(filter.subbrand_cd+"%")),
															new Pattern("%PROD_CATG_CODE%",(filter.prod_catg_code+"%")),
															new Pattern("%COSE%",(filter.cose+"%")),
															new Pattern("%LESCOMPLEX%",(filter.les_complex+"%")),
															new Pattern("%SMILE%",(filter.smile+"%")),
															new Pattern("%SEI%",(filter.sei+"%")),
															new Pattern("%BCRSRenewal%",(filter.bcrs_renewal+"%")),
															new Pattern("%DNSO%",(filter.dnso+"%")),
															new Pattern("%SmallDeals%",(filter.small_deals+"%")),
															new Pattern("%TOP25%",(filter.top25+"%")),
															new Pattern("%SECTORS%",(filter.sectors+"%")),
															new Pattern("%INDUSTRY%",(filter.industry+"%")),
															new Pattern("%CLIENT_NAME%",(filter.client_name+"%")),
															new Pattern("%CLIENT_NO%",(filter.client_no+"%")),
															new Pattern("%CUST_NAME%",(filter.cust_name+"%")),
															new Pattern("%CUST_NO%",(filter.cust_no+"%")),
															new Pattern("%COV_NAME%",(filter.cov_name+"%")),
															new Pattern("%COV_ID%",(filter.cov_id+"%")),
															new Pattern("%TERRITORY%",(filter.territory+"%")),
															new Pattern("%INS_SAL_INV%",(filter.ins_sal_inv+"%")),
															new Pattern("%SLE_STAGE_GROUP%",(filter.sle_stage_group+"%")),
															new Pattern("%OWNING_ORG%",(filter.owning_org+"%")),
										//					new Pattern("%OPPTY_ROLE%",(filter.oppty_role+"%")),
															new Pattern("%CHANL_NAME%",(filter.chanl_name+"%")),
										//					new Pattern("%AGE_RANGE_NAME%",(filter.age_range_name+"%")),
															new Pattern("%STUCK_PIPELINE_INDC%",(filter.stuck_pipeline_indc+"%"))//,
//															new Pattern("%DUP_OPP_INDC%",(filter.dup_opp_indc+"%")),
										//					new Pattern("%DET_REV_CLIP%",(filter.det_rev_clip+"%")),
										//					new Pattern("%TOTAL_REV_CLIP%",(filter.total_rev_clip+"%"))
															));
			if (!dbContentTmp.isEmpty()){
				for(int i = 0; i < dbContentTmp.size(); i++)
				{
					listOfDetailNumbers.add(dbContentTmp.get(i).get(0));
					System.out.println(listOfDetailNumbers.get(i));
				}
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		return listOfDetailNumbers;
	}
}

